var iter;
var chargeMsg ="";
var cashMsg="";
var icon=cache+"/images/finger.png";
var msg=""; 
jQuery(function()
{
   iter= window.setInterval(queryFundsReq,5000);	
}		
);

/***查询是否存在待处理的帐变信息**/
function queryFundsReq()
{
	   jQuery.post(
	            base+"/funds/fundsReq.do", 
	            function(result){
	            	var data=eval("("+result+")");
	                if(data&&data.length>0)//存在未处理的充值订单或者提现请求
	                {
	                     for(var i=0;i<data.length;i++)
	                     {
	                    	 if(data[i].tipsMsgCount>0)
	                    	  {
	                    		  playVoice(base+"/media/"+data[i].tipsVoide, "mediaDiv");
		                    	  showFundsTips(data[i]);
		                    	  return;
	                    	  }
	                     }
	                }
	    });
}


function queryUserRecharge()
{
	//jQuery("#content").attr("src",base+"/reportMain.do?repCode=pagingUserCashRequest&pageIndex=1&pageSize=15");
	jQuery("#content").attr("src",base+"/funds/fundsCharge.do");
}


function queryUserCash()
{
	//jQuery("#content").attr("src",base+"/reportMain.do?repCode=pagingUserRecharge&pageIndex=1&pageSize=15&chargeStatus=0");
	jQuery("#content").attr("src",base+"/funds/fundsCash.do");
}


/**弹出提示层信息**/
function showFundsTips(data)
{
	  var dataType=data.fundsType;
	  var title ="提现请求";
	  if(data.tipsMsgCount>0)
	  {
		  if(dataType=="userCharge")
		  {
			  title ="充值请求";
			  msg="你有"+data.tipsMsgCount+"条充值请求待处理，<a href='javascript:queryUserRecharge()'>前去处理。</a><br><br>";
		  }
		  else
		  {
			  msg="你有"+data.tipsMsgCount+"条提现请求待处理，<a href='javascript:queryUserCash()'>前去处理。</a><br><br>";
		  }
		 
		  jQuery.sticky({
		        icon         : icon,
		        title        : title,
		        body         : msg,
		        position     : "bottom-right",
		        useAnimateCss: false,
		        onShown      : function(id){
		          console.log('shown', id);
		        },
		        onHidden     : function(id){
		          console.log('hidden', id);
		        }
		      });	
	  }

}


/**播放提示声音**/
function playVoice (src, domId){
	//if(!global.isVoice) return;
    var $dom=$('#'+domId);
	 if(navigator.userAgent.indexOf('MSIE') >= 0){
        if($dom.length){
            $dom[0].src=src;
        }else{
            $('<bgsound>',{src:src, id:domId}).appendTo('body');
        }
    }else{
        if($dom.length){
            $dom[0].play();
        }else{
            $('<audio>',{src:src, id:domId}).appendTo('body')[0].play();
        }
    }
}